package xin.core.jpa.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import xin.core.jpa.JpaConstant;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import java.util.Date;


@MappedSuperclass
@Cacheable
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true, of = {})
public abstract class AuditableEntity extends UUIDEntity {

	protected Boolean locked;

	protected Boolean deleted;

	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(updatable = false)
	protected Date createTime;

	@Column(length = JpaConstant.UidColumnLength, updatable = false)
	protected String createBy;

	@Transient
	protected String createByName;

	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(insertable = false)
	protected Date lastModifyTime;

	@Column(length = JpaConstant.UidColumnLength, insertable = false)
	protected String lastModifyBy;

	@Transient
	protected String lastModifyByName;

	@Column(length = JpaConstant.PriorityColumnLength)
	protected Integer priority;
}
